include Makefile.d

all: server

server: prepare $(MODULES)
	@$(MAKE) -f Makefile.$@ -C ./output/bin
	@cp ./conf/* ./output/conf -v

prepare:
	@if [ ! -d ./output ]; then mkdir ./output;	fi
	@if [ ! -d ./output/bin ]; then mkdir ./output/bin;	fi
	@if [ ! -d ./output/conf ]; then mkdir ./output/conf;	fi
	@if [ ! -d ./output/data ]; then mkdir ./output/data;	fi
	@if [ ! -d ./output/log ]; then mkdir ./output/log;	fi
	@if [ ! -d ./output/status ]; then mkdir ./output/status;	fi
	@if [ ! -d ./output/status/wordsegsvr ]; then mkdir ./output/status/wordsegsvr;	fi
	@cp -v Makefile.server ./output/bin -v

$(MODULES):
	@$(MAKE) -f Makefile.$@ -C $(SRCDIR)/$@
	@mv $(SRCDIR)/$@/*.o ./output/bin

clean:
	rm -rf ./output/ -v
	rm -rf $(SRCDIR)/*/*.o -v